package com.yunhuisu.mapper;

import com.yunhuisu.pojo.Books;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
public interface BookMapper {

    @Select("SELECT * FROM books")
    List<Books> findAllBook();

    @Select("SELECT * FROM books WHERE bookID = #{bookID}")
    Books findByIdBook(@Param("bookID")int bookID);

    @Insert("INSERT INTO books(bookName, bookCounts, detail) VALUES (#{bookName}, #{bookCounts}, #{detail})")
    boolean addBook(Books books);

    @Update("UPDATE books SET bookName = #{bookName},bookCounts = #{bookCounts},detail = #{detail}  WHERE bookID = #{bookID}")
    boolean updateBook(Books books);

    @Delete("DELETE FROM books WHERE bookID = #{bookID}")
    boolean byIdDeleteBook(@Param("bookID")int bookID);
}
